#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>

/**
 * 结构体的深拷贝
 */

struct Student
{
    int num;
    char *name; // 此时为指针变量，直接赋值浅拷贝可能会造成问题
};

void test01()
{

    Student lucy;
    lucy.num = 100;
    lucy.name = new char[32];
    strcpy(lucy.name, "lucy");

    Student bob;
    // 浅拷贝
    // bob = lucy;

    // 深拷贝
    bob.num = lucy.num;
    bob.name = new char[32];
    strcpy(bob.name, lucy.name);

    // 如果这时重复释放
    delete[] lucy.name;
    delete[] bob.name;
}

int main()
{

    std::cout << "struct study " << std::endl;
    return 0;
}